package com.liuzu.esys.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.liuzu.esys.bo.ItemBo;
import com.liuzu.esys.pojo.Item;
import com.liuzu.esys.service.ItemService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component
@Scope("prototype")
public class WebItemListener extends AnalysisEventListener<ItemBo> {
    @Autowired
    ItemService itemService;
    @Override
    public void invoke(ItemBo itemBo, AnalysisContext analysisContext) {
        System.out.println(itemBo);
        Item item = new Item();
        //属性拷贝
        BeanUtils.copyProperties(itemBo,item);
        itemService.addItem(item);



    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
